<?php
$this->pageTitle = Yii::app()->name;
$this->breadcrumbs=array(
	'采购',
);
include_once('menu.php');
$this->widget('application.extensions.fancybox.EFancyBox', array('target' => '.update', 'config' => array('width' => 830, 'height' => 520,'type'=>'iframe','hideOnOverlayClick'=>false)));
Yii::import('ext.qtip.QTip');
QTip::qtip('span[title]');
?>
<script>
function del(pid,name){
	if(!confirm('确认要删除:'+name)){
		return false;
	}
	$.post('<?php echo CHtml::normalizeUrl(array('/psi/delPricing'));?>',{'pid':pid}, function (data) {
        var ret = $.parseJSON(data);
        if (ret != null && ret.success != null && ret.success) {
			alert(ret.msg);
			location.reload(true);
        }
	});	
}
</script>
<div style="width:100%; float:left; margin-bottom:10px; text-align:right;">
	<form action="" name="jobForm" id="jobForm" method="get">
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
		<tr>
			<td width="13%" class="td_right"><?php echo $labels['OrderName']; ?>: </td>
			<td width="20%"><input type="text" name="OrderName" value="<?php if(isset($search['OrderName']))echo $search['OrderName'];?>" id="OrderName" class="input_size" /></td>
			<td width="14%" class="td_right"><?php echo $labels['ProductModel']; ?>: </td>
			<td width="20%"><input type="text" name="ProductModel" value="<?php if(isset($search['ProductModel']))echo $search['ProductModel'];?>" id="ProductModel" class="input_size" /></td>
			<td width="13%" class="td_right"><?php echo $labels['Buyer']; ?>: </td>
			<td><input type="text" name="Buyer" value="<?php if(isset($search['Buyer']))echo $search['Buyer'];?>" id="Buyer" class="input_size" /></td>
		</tr>
		<tr>
			<td class="td_right"><?php echo $labels['ReceiptNo']; ?>: </td>
			<td><input type="text" name="ReceiptNo" value="<?php if(isset($search['ReceiptNo']))echo $search['ReceiptNo'];?>" id="ReceiptNo" class="input_size" /></td>			
			<td class="td_right"><?php echo $labels['ProductDetail']; ?>: </td>
			<td><input type="text" name="ProductDetail" value="<?php if(isset($search['ProductDetail']))echo $search['ProductDetail'];?>" id="ProductDetail" class="input_size" /></td>
			<td class="td_right"><?php echo $labels['ToLAMethod']; ?>: </td>
			<td><?php echo CHtml::dropDownList('ToLAMethod',$search['ToLAMethod'], Yii::app()->params['method'],array('empty'=>array(''=>'请选择'),'class'=>'input_size7'));?></td>
		</tr>
		<tr>			
			<td class="td_right"><?php echo $labels['Event']; ?>: </td>
			<td><?php echo CHtml::dropDownList('Event',$search['Event'], Yii::app()->params['event'],array('empty'=>array(''=>'请选择'),'class'=>'input_size7'));?></td>
			<td class="td_right"><?php echo $labels['Destination1']; ?>: </td>
			<td><input type="text" name="Destination1" value="<?php if(isset($search['Destination1']))echo $search['Destination1'];?>" id="Destination1" class="input_size" /></td>
			<td class="td_right"><?php echo $labels['Destination2']; ?>: </td>
			<td><input type="text" name="Destination2" value="<?php if(isset($search['Destination2']))echo $search['Destination2'];?>" id="Destination2" class="input_size" /></td>
		</tr>
		<tr>
			<td class="td_right"><?php echo $labels['Date']; ?>: </td>
			<td colspan="2">
			<input type="text" name="sDate" id="sDate" value="<?= $search['sDate'] ?>" readonly="readonly" style="width:70px;" /><img onclick="displayCalendar(document.jobForm.sDate,'yyyymmdd',this)" style="cursor:pointer;" width="25" src="images/calendar.png" />
			-
			<input type="text" name="eDate" id="eDate" value="<?= $search['eDate'] ?>" readonly="readonly" style="width:70px;" /><img onclick="displayCalendar(document.jobForm.eDate,'yyyymmdd',this)" style="cursor:pointer;" width="25" src="images/calendar.png" />			
			</td>
			<td class="td_right"><?php echo $labels['BoxNum']; ?>: </td>
			<td colspan="2">
			<input type="text" name="sCreateTime" id="sCreateTime" value="<?= $search['sCreateTime'] ?>" readonly="readonly" style="width:70px;" /><img onclick="displayCalendar(document.jobForm.sCreateTime,'yyyymmdd',this)" style="cursor:pointer;" width="25" src="images/calendar.png" />
			-
			<input type="text" name="eCreateTime" id="eCreateTime" value="<?= $search['eCreateTime'] ?>" readonly="readonly" style="width:70px;" /><img onclick="displayCalendar(document.jobForm.eCreateTime,'yyyymmdd',this)" style="cursor:pointer;" width="25" src="images/calendar.png" />			
			</td>
		</tr>
		<tr>
			<td colspan="6" style="text-align:right;"><a style="margin-right:50px;" href="<?=Yii::app()->createUrl('psi/exportPricing',$search)?>" target="_blank"><img src="images/down.png" border="0" /></a><a style="margin-right:50px;" href="<?=Yii::app()->createUrl('psi/pricing')?>"><img src="images/shua.png" border="0" /></a><input type="image" src="images/go.png" name="jobSub" id="jobSub" value="Go" /></td>			
		</tr>
	</table>		
		<input type="hidden" name="r" value="psi/pricing" />
	</form>
</div>
<div style="width:100%;float:right;margin-bottom:10px;">记录总数:<?=$pages->itemCount?></div>
<div style="width:100%; float:left; margin-bottom:10px; text-align:right;">
<table cellspacing="0" cellpadding="0" width="100%" class="tbl" style="float:left;">
	<tr class="head">		
		<td width="10%"><?php echo $labels['Date']; ?></td>
		<td width="10%"><?php echo $labels['BoxNum']; ?></td>
		<td width="10%"><?php echo $labels['ProductModel']; ?></td>
		<td width="21%"><?php echo $labels['ProductDetail']; ?></td>
		<td width="6%"><?php echo $labels['ProductLink']; ?></td>
		<td width="6%"><?php echo $labels['PQuantity']; ?></td>
		<td width="8%"><?php echo $labels['Balance']; ?></td>		
		<td width="6%"><?php echo $labels['Event']; ?></td>
		<td width="10%"><?php echo $labels['ToLAMethod']; ?></td>
		<td width="6%">批量更新</td>
		<td>详情</td>
	</tr>
	<?php
    $i = 0;
    $cssArr = array(0 => 'even', 1 => 'odd', 2 => 'three');
    foreach ($rowTable as $item) {
        $trClass = $cssArr[$i % 3];
        $i++;
        ?>
	<tr class="<?= $trClass ?>">		
		<td>
			<?=$item->Date?>
		</td>
		<td>
			<?=$item->BoxNum?>
		</td>
		<td>
			<?=$item->ProductModel?>
		</td>
		<td>
			<span title="<span style='line-height:20px; font-size:12px;'><?=$item->ProductDetail?></span>"><?=Helper::truncate_utf8_string($item->ProductDetail,10,'')?></span>
		</td>
		<td style="text-align:center;">
		<?php
		if($item->ProductLink){
		?>		
		<a href="<?=Helper::linkFormat($item->ProductLink)?>" target="_blank">打开</a>
		<?php
		}
		?>			
		</td>
		<td style="text-align:center;">
			<?=$item->PQuantity?>
		</td>
		<td style="text-align:center;">
			<?=$item->Balance?>
		</td>		
		<td style="text-align:center;">
			<?=$item->Event?>
		</td>
		<td style="text-align:center;">
			<?=$item->ToLAMethod?>
		</td>
		<td style="text-align:center;">
		<?php
		if($item->ReceiptNo){
		?>
			<a class="update" href="<?=Yii::app()->createUrl('psi/batchUpdate',array('ReceiptNo'=>$item->ReceiptNo))?>">更新</a>
		<?php
		}
		?>
		</td>
		<td style="text-align:center;">
			<a target="_blank" href="<?=Yii::app()->createUrl('psi/update',array('id'=>$item->PricingIndex))?>">详情</a>
		</td>
	</tr>
	<?php
    }
    ?>
</table>
</div>
<div id="pager" align="center">
<?php  
	$this->widget('CLinkPager',array(  
		'header'=>'',  
		'firstPageLabel' => '<<',
		'lastPageLabel' => '>>',
		'prevPageLabel' => '<',
		'nextPageLabel' => '>',
		'pages' => $pages,  
		'maxButtonCount'=>13  
		));  
?>
</div>